package com.attendance.controller;

import com.attendance.monitoring.Server;
import com.attendance.web.Result;
import com.attendance.web.ResultCode;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.security.RolesAllowed;

/**
 * 服务器监控
 *
 * @author ruoyi
 */
@Controller
@RequestMapping("/system/monitor/server")
@RolesAllowed("ADMIN")
public class ServerController {

    @GetMapping("/init")
    @ResponseBody
    public Result getInfo() throws Exception {
        Server server = new Server();
        server.copyTo();
        return new Result(ResultCode.SUCCESS, server);
    }

    @GetMapping()
    public ModelAndView server() throws Exception {
        ModelAndView modelAndView = new ModelAndView("/system/monitor/server");
        Server server = new Server();
        server.copyTo();
        modelAndView.addObject(server);
        return modelAndView;
    }
}